package com.hx.study.votes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.hx.study.votes.domain.ElVotes;
import com.hx.study.votes.service.IElVotesService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hx.common.annotation.Log;
import com.hx.common.core.controller.BaseController;
import com.hx.common.core.domain.AjaxResult;
import com.hx.common.enums.BusinessType;
import com.hx.common.utils.poi.ExcelUtil;
import com.hx.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ${author}
 * @date 2023-05-31
 */
@RestController
@RequestMapping("/votes")
public class ElVotesController extends BaseController {
    @Autowired
    private IElVotesService elVotesService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('study:votes:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElVotes elVotes)
    {
        startPage();
        List<ElVotes> list = elVotesService.selectElVotesList(elVotes);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('study:votes:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElVotes elVotes)
    {
        List<ElVotes> list = elVotesService.selectElVotesList(elVotes);
        ExcelUtil<ElVotes> util = new ExcelUtil<ElVotes>(ElVotes.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('study:votes:query')")
    @GetMapping(value = "/{votesId}")
    public AjaxResult getInfo(@PathVariable("votesId") Integer votesId)
    {
        return success(elVotesService.selectElVotesByVotesId(votesId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('study:votes:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElVotes elVotes)
    {
        return toAjax(elVotesService.insertElVotes(elVotes));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('study:votes:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElVotes elVotes)
    {
        return toAjax(elVotesService.updateElVotes(elVotes));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('study:votes:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{votesIds}")
    public AjaxResult remove(@PathVariable Integer[] votesIds)
    {
        return toAjax(elVotesService.deleteElVotesByVotesIds(votesIds));
    }
}
